<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [];
        var numb = 10000000;
        var arrA = [],
            arrB = [],
            arrC = [];
        for(var i = 0 ; i < numb; i++){
            arr.push(i);
        }
        var j = 0;
        i = 0;
        
        //while
        console.time('while');
        while ( j < arr.length){
            arrB[j] = j;
            j++;
        }
        console.timeEnd('while');
        //for 
        console.time('for');
        for(; i < arr.length; i++){
            arrA[i] = i;
        }
        console.timeEnd('for');
        //forEach
        console.time('forEach');
        arr.forEach(function(v,i){
            arrC[i] = i;
        });
        console.timeEnd('forEach');
    </script>
</body>
</html>